package cn.puge.mertisfront.controller;


import cn.puge.commonutils.R;
import cn.puge.mertisfront.entity.PugeUser;
import cn.puge.mertisfront.service.PugeUserService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import javax.xml.ws.Action;
import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *用户
 * @author LIJW
 * @since 2020-08-28
 */
@RestController
@RequestMapping("/mertisfront/puge-user")
@CrossOrigin
public class PugeUserController {

   @Autowired
   private PugeUserService pugeUserService;

    //查询总排名
    @GetMapping("getAllGread")
    public R getAllGread(){
        QueryWrapper<PugeUser> queryWrapper = new QueryWrapper<>();
        queryWrapper.orderByDesc("allgread");
        queryWrapper.select("allgread","name","ch");
        List<PugeUser> list = pugeUserService.list(queryWrapper);

        return R.ok().data("list",list);
    }

    //查询月排名
    @GetMapping("getMonthGread")
    public R getMonthGread(){
        QueryWrapper<PugeUser> queryWrapper = new QueryWrapper<>();
        queryWrapper.orderByDesc("monthgread");
        queryWrapper.select("monthgread","name","ch");
        List<PugeUser> list = pugeUserService.list(queryWrapper);

        return R.ok().data("list",list);
    }
}

